﻿#include"OrderModel.h"
OrderModel::OrderModel() :ProductModel()
{
}

OrderModel::OrderModel(const ProductModel& product)
{
	*(ProductModel*)this = product;
}

OrderModel::OrderModel(const QVariantMap& data, bool base64)
{
	setData(data,base64);
}

OrderModel::~OrderModel()
{
}

QStringList OrderModel::fields() const
{
	return ProductModel::fields()<<"order_id"<< "account";
}

QVariantMap OrderModel::toMap(const QStringList& fields, bool base64) const
{
	auto map = ProductModel::toMap(fields, base64);
	if (fields.contains("order_id"))
		map["order_id"] = m_order_id;
	if (fields.contains("account"))
		map["account"] = m_account;
	return map;
}

void OrderModel::setData(const QVariantMap& data, bool base64)
{
	ProductModel::setData(data,base64);
	if (data.contains("order_id"))
		m_order_id = data["order_id"].toULongLong();
	if (data.contains("account"))
		m_account = data["account"].toString();
}

QString OrderModel::createTableSql(const QString& tableName) const
{
	return QString("CREATE TABLE `%1` ("
		"order_id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,"//id
		"account VARCHAR(50),"//账号
		"product_id BIGINT UNSIGNED ,"//id
		"name VARCHAR(50),"//名字
		"type VARCHAR(50),"//类型
		"price DOUBLE ,"//价格
		"number BIGINT UNSIGNED,"//数量
		"mtime DATETIME ,"//修改时间
		"ctime DATETIME "//创建时间
		")").arg(tableName);
}

quint64 OrderModel::order_id() const
{
	return m_order_id;
}


QString OrderModel::account() const
{
	return m_account;
}

void OrderModel::setOrder_id(quint64 id)
{
	m_order_id = id;
}

void OrderModel::setAccount(const QString& account)
{
	m_account = account;
}
